package 刷题.leedcode226;
/*
递归的进行翻转
保存原来的右子树
 */
public class Solution1 {
    public TreeNode invertTree(TreeNode root){
        if(root == null){
            return null;
        }
        //保存右子树
        TreeNode rightTree = root.right;
        root.left = invertTree(root.right);
        root.right = invertTree(root.left);
        return root;
    }
}
